
package avenue;

import java.awt.Toolkit;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.persistence.EntityManager;
import javax.swing.JFrame;
import javax.swing.JMenuItem;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import model.AppUser;
import model.DBManager;

/**
 *
 * @author Team-2
 */
public class Avenue extends javax.swing.JFrame {
    private final EntityManager em;

    /**
     * Creates new form Avenue
     */
    public Avenue() {
        
        LoginForm lf = new LoginForm(this);
        lf.setIconImage(Toolkit.getDefaultToolkit().getImage(Session.imgPath + "loginIcon.gif"));
        lf.setVisible(true);
        lf.setLocationRelativeTo(null); //center form
        setEnabled(false); //disable this form unti succeess login
        em = DBManager.em;
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jTxtUserStation = new javax.swing.JTextField();
        jTxtCurrentUser = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jToolBar1 = new javax.swing.JToolBar();
        tollIconButton = new javax.swing.JButton();
        usersIconButton = new javax.swing.JButton();
        rolesIconButton = new javax.swing.JButton();
        customersIconButton = new javax.swing.JButton();
        programsIconButton = new javax.swing.JButton();
        customerTransIconButton = new javax.swing.JButton();
        cardTransIconButton = new javax.swing.JButton();
        exitIconButton = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMnuAdmin = new javax.swing.JMenu();
        jMnuUsers = new javax.swing.JMenuItem();
        jMnuCustomers = new javax.swing.JMenuItem();
        jMnuRoles = new javax.swing.JMenuItem();
        jMnuPrograms = new javax.swing.JMenuItem();
        jMnuTolls = new javax.swing.JMenu();
        jMnuCollectToll = new javax.swing.JMenuItem();
        jMnuTransactions = new javax.swing.JMenu();
        jMnuCardTransactions = new javax.swing.JMenuItem();
        jMnuCustomerTransactions = new javax.swing.JMenuItem();
        jMnuExit = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Tele-Pass");
        setIconImages(null);

        jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jTxtUserStation.setEditable(false);
        jTxtUserStation.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        jTxtUserStation.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTxtUserStationActionPerformed(evt);
            }
        });

        jTxtCurrentUser.setEditable(false);
        jTxtCurrentUser.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        jTxtCurrentUser.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));

        jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/UserIcon.png"))); // NOI18N

        jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/station.png"))); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(4, 4, 4)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTxtUserStation, javax.swing.GroupLayout.PREFERRED_SIZE, 217, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 145, Short.MAX_VALUE)
                .addComponent(jTxtCurrentUser, javax.swing.GroupLayout.PREFERRED_SIZE, 273, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel3))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jTxtCurrentUser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jTxtUserStation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)))
        );

        jLabel3.getAccessibleContext().setAccessibleName("jLbUserIcon");

        jToolBar1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jToolBar1.setRollover(true);

        tollIconButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/tollIcon.png"))); // NOI18N
        tollIconButton.setText("Διέλευση");
        tollIconButton.setToolTipText("Διέλευση Οχήματος");
        tollIconButton.setBorder(null);
        tollIconButton.setFocusable(false);
        tollIconButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        tollIconButton.setMaximumSize(new java.awt.Dimension(75, 50));
        tollIconButton.setMinimumSize(new java.awt.Dimension(75, 50));
        tollIconButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        tollIconButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tollIconButtonMouseClicked(evt);
            }
        });
        jToolBar1.add(tollIconButton);

        usersIconButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/muserIcon.png"))); // NOI18N
        usersIconButton.setText("Χρήστες");
        usersIconButton.setFocusable(false);
        usersIconButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        usersIconButton.setMaximumSize(new java.awt.Dimension(75, 50));
        usersIconButton.setMinimumSize(new java.awt.Dimension(75, 50));
        usersIconButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        usersIconButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                usersIconButtonMouseClicked(evt);
            }
        });
        jToolBar1.add(usersIconButton);

        rolesIconButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/rolesIcon.png"))); // NOI18N
        rolesIconButton.setText("  Ρόλοι  ");
        rolesIconButton.setFocusable(false);
        rolesIconButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        rolesIconButton.setMaximumSize(new java.awt.Dimension(75, 50));
        rolesIconButton.setMinimumSize(new java.awt.Dimension(75, 50));
        rolesIconButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        rolesIconButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                rolesIconButtonMouseClicked(evt);
            }
        });
        jToolBar1.add(rolesIconButton);

        customersIconButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/custIcon.png"))); // NOI18N
        customersIconButton.setText("Πελάτες");
        customersIconButton.setFocusable(false);
        customersIconButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        customersIconButton.setMaximumSize(new java.awt.Dimension(75, 50));
        customersIconButton.setMinimumSize(new java.awt.Dimension(75, 50));
        customersIconButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        customersIconButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                customersIconButtonMouseClicked(evt);
            }
        });
        jToolBar1.add(customersIconButton);

        programsIconButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/programmsIcon.png"))); // NOI18N
        programsIconButton.setText("Προγράμματα");
        programsIconButton.setFocusable(false);
        programsIconButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        programsIconButton.setMaximumSize(new java.awt.Dimension(75, 50));
        programsIconButton.setMinimumSize(new java.awt.Dimension(75, 50));
        programsIconButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        programsIconButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                programsIconButtonMouseClicked(evt);
            }
        });
        jToolBar1.add(programsIconButton);

        customerTransIconButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/custHistIcon.png"))); // NOI18N
        customerTransIconButton.setText("Κίν. Πελατών");
        customerTransIconButton.setFocusable(false);
        customerTransIconButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        customerTransIconButton.setMaximumSize(new java.awt.Dimension(75, 50));
        customerTransIconButton.setMinimumSize(new java.awt.Dimension(75, 50));
        customerTransIconButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        customerTransIconButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                customerTransIconButtonMouseClicked(evt);
            }
        });
        jToolBar1.add(customerTransIconButton);

        cardTransIconButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cardHistIcon.png"))); // NOI18N
        cardTransIconButton.setText("Κίνηση Καρτας");
        cardTransIconButton.setFocusable(false);
        cardTransIconButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        cardTransIconButton.setMaximumSize(new java.awt.Dimension(75, 50));
        cardTransIconButton.setMinimumSize(new java.awt.Dimension(75, 50));
        cardTransIconButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        cardTransIconButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                cardTransIconButtonMouseClicked(evt);
            }
        });
        jToolBar1.add(cardTransIconButton);

        exitIconButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/exit.png"))); // NOI18N
        exitIconButton.setText("Έξοδος");
        exitIconButton.setFocusable(false);
        exitIconButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        exitIconButton.setMaximumSize(new java.awt.Dimension(75, 50));
        exitIconButton.setMinimumSize(new java.awt.Dimension(75, 50));
        exitIconButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        exitIconButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                exitIconButtonMouseClicked(evt);
            }
        });
        jToolBar1.add(exitIconButton);

        jMnuAdmin.setText("Διαχείριση");

        jMnuUsers.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.ALT_MASK));
        jMnuUsers.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/muserIcon.png"))); // NOI18N
        jMnuUsers.setText("Χρήστες");
        jMnuUsers.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMnuUsersActionPerformed(evt);
            }
        });
        jMnuAdmin.add(jMnuUsers);

        jMnuCustomers.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.ALT_MASK));
        jMnuCustomers.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/custIcon.png"))); // NOI18N
        jMnuCustomers.setText("Πελάτες");
        jMnuCustomers.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMnuCustomersActionPerformed(evt);
            }
        });
        jMnuAdmin.add(jMnuCustomers);

        jMnuRoles.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R, java.awt.event.InputEvent.ALT_MASK));
        jMnuRoles.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/rolesIcon.png"))); // NOI18N
        jMnuRoles.setText("Ρόλοι");
        jMnuRoles.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMnuRolesActionPerformed(evt);
            }
        });
        jMnuAdmin.add(jMnuRoles);

        jMnuPrograms.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.ALT_MASK));
        jMnuPrograms.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/programmsIcon.png"))); // NOI18N
        jMnuPrograms.setText("Προγράμματα");
        jMnuPrograms.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMnuProgramsActionPerformed(evt);
            }
        });
        jMnuAdmin.add(jMnuPrograms);

        jMenuBar1.add(jMnuAdmin);

        jMnuTolls.setText("Διόδια");

        jMnuCollectToll.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_D, java.awt.event.InputEvent.ALT_MASK));
        jMnuCollectToll.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/tollIcon.png"))); // NOI18N
        jMnuCollectToll.setText("Διέλευση");
        jMnuCollectToll.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMnuCollectTollActionPerformed(evt);
            }
        });
        jMnuTolls.add(jMnuCollectToll);

        jMenuBar1.add(jMnuTolls);

        jMnuTransactions.setText("Κινήσεις");

        jMnuCardTransactions.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/cardHistIcon.png"))); // NOI18N
        jMnuCardTransactions.setText("Κίνηση Κάρτας");
        jMnuCardTransactions.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMnuCardTransactionsActionPerformed(evt);
            }
        });
        jMnuTransactions.add(jMnuCardTransactions);

        jMnuCustomerTransactions.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/custHistIcon.png"))); // NOI18N
        jMnuCustomerTransactions.setText("Κίνηση Πελάτη");
        jMnuCustomerTransactions.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMnuCustomerTransactionsActionPerformed(evt);
            }
        });
        jMnuTransactions.add(jMnuCustomerTransactions);

        jMenuBar1.add(jMnuTransactions);

        jMnuExit.setText("Έξοδος");
        jMnuExit.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jMnuExitMousePressed(evt);
            }
        });
        jMnuExit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMnuExitActionPerformed(evt);
            }
        });
        jMenuBar1.add(jMnuExit);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 201, Short.MAX_VALUE)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    
    
    private void jMnuCustomersActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMnuCustomersActionPerformed

        try {
              openForm(Class.forName("customers.ListClientForm"), "custIcon.png");
        } catch (Exception ex) {
              Logger.getLogger(Avenue.class.getName()).log(Level.SEVERE, null, ex);
        }             

    }//GEN-LAST:event_jMnuCustomersActionPerformed

    private void jMnuUsersActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMnuUsersActionPerformed

        try {
              openForm(Class.forName("users.ListUsersForm"), "muserIcon.png");
        } catch (Exception ex) {
              Logger.getLogger(Avenue.class.getName()).log(Level.SEVERE, null, ex);
        }          

    }//GEN-LAST:event_jMnuUsersActionPerformed

    private void jMnuRolesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMnuRolesActionPerformed

        try {
              openForm(Class.forName("roles.ListRolesForm"), "rolesIcon.png");
        } catch (Exception ex) {
              Logger.getLogger(Avenue.class.getName()).log(Level.SEVERE, null, ex);
        }        

    }//GEN-LAST:event_jMnuRolesActionPerformed

    private void jMnuCollectTollActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMnuCollectTollActionPerformed

        try {
              openForm(Class.forName("tolls.CollectTollForm"), "tollIcon.png");
        } catch (Exception ex) {
              Logger.getLogger(Avenue.class.getName()).log(Level.SEVERE, null, ex);
        } 

    }//GEN-LAST:event_jMnuCollectTollActionPerformed

    private void jMnuProgramsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMnuProgramsActionPerformed

        try {
              openForm(Class.forName("program.ListProgramForm"), "programmsIcon.png");
        } catch (Exception ex) {
              Logger.getLogger(Avenue.class.getName()).log(Level.SEVERE, null, ex);
        } 
        
    }//GEN-LAST:event_jMnuProgramsActionPerformed

    private void jMnuCardTransactionsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMnuCardTransactionsActionPerformed
        
        try {
              openForm(Class.forName("transactions.CardTransactions"), "cardHistIcon.png");
        } catch (Exception ex) {
              Logger.getLogger(Avenue.class.getName()).log(Level.SEVERE, null, ex);
        }  

    }//GEN-LAST:event_jMnuCardTransactionsActionPerformed

    private void jMnuCustomerTransactionsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMnuCustomerTransactionsActionPerformed
                                                 
        try {
              openForm(Class.forName("transactions.CustomerTransactions"), "custHistIcon.png");
        } catch (Exception ex) {
              Logger.getLogger(Avenue.class.getName()).log(Level.SEVERE, null, ex);
        }        
        
    }//GEN-LAST:event_jMnuCustomerTransactionsActionPerformed

    private void jMnuExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMnuExitActionPerformed
     // TODO add your handling code here:
    }//GEN-LAST:event_jMnuExitActionPerformed

    private void jMnuExitMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMnuExitMousePressed
       
        em.close();
        System.exit(0);
    }//GEN-LAST:event_jMnuExitMousePressed

    private void jTxtUserStationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTxtUserStationActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTxtUserStationActionPerformed

    private void tollIconButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tollIconButtonMouseClicked

        try {
              openForm(Class.forName("tolls.CollectTollForm"), "tollIcon.png");
        } catch (Exception ex) {
              Logger.getLogger(Avenue.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }//GEN-LAST:event_tollIconButtonMouseClicked

    private void usersIconButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_usersIconButtonMouseClicked
        
        try {
              openForm(Class.forName("users.ListUsersForm"), "muserIcon.png");
        } catch (Exception ex) {
              Logger.getLogger(Avenue.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }//GEN-LAST:event_usersIconButtonMouseClicked

    private void rolesIconButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_rolesIconButtonMouseClicked

        try {
              openForm(Class.forName("roles.ListRolesForm"), "rolesIcon.png");
        } catch (Exception ex) {
              Logger.getLogger(Avenue.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }//GEN-LAST:event_rolesIconButtonMouseClicked

    private void customersIconButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_customersIconButtonMouseClicked

        try {
              openForm(Class.forName("customers.ListClientForm"), "custIcon.png");
        } catch (Exception ex) {
              Logger.getLogger(Avenue.class.getName()).log(Level.SEVERE, null, ex);
        }
                
    }//GEN-LAST:event_customersIconButtonMouseClicked

    private void programsIconButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_programsIconButtonMouseClicked
   
        try {
              openForm(Class.forName("program.ListProgramForm"), "programmsIcon.png");
        } catch (Exception ex) {
              Logger.getLogger(Avenue.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }//GEN-LAST:event_programsIconButtonMouseClicked

    private void customerTransIconButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_customerTransIconButtonMouseClicked

        try {
              openForm(Class.forName("transactions.CustomerTransactions"), "custHistIcon.png");
        } catch (Exception ex) {
              Logger.getLogger(Avenue.class.getName()).log(Level.SEVERE, null, ex);
        }
                
    }//GEN-LAST:event_customerTransIconButtonMouseClicked

    private void cardTransIconButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cardTransIconButtonMouseClicked

        try {
              openForm(Class.forName("transactions.CardTransactions"), "cardHistIcon.png");
        } catch (Exception ex) {
              Logger.getLogger(Avenue.class.getName()).log(Level.SEVERE, null, ex);
        }
                
    }//GEN-LAST:event_cardTransIconButtonMouseClicked

    private void exitIconButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_exitIconButtonMouseClicked
        
         em.close();
         System.exit(0);
         
    }//GEN-LAST:event_exitIconButtonMouseClicked

    /**
     * Open a form that given in parameter className
     * @param calssName
     * @param imageIcon
     */
   private void openForm(Class calssName, String imageIcon) {
       
       try {
            JFrame frm = (JFrame)calssName.newInstance();
            frm.setIconImage(Toolkit.getDefaultToolkit().getImage(Session.imgPath + imageIcon));
            frm.setVisible(true);
            frm.setLocationRelativeTo(null); //center form          
       }catch (Exception ex) {
           System.out.println(ex);
       }
   } 
    
/**
 * Set the info text for the station that user belongs and the name of user
 * @param stationText
 * @param userText 
 */
    public void setInfoFields(String stationText, String userText) {
        
        jTxtUserStation.setText(stationText);
        jTxtCurrentUser.setText(userText);
    }

    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */

        //</editor-fold>               
        
        //Windows Forms Look
        try {
                   // Set System L&F
               UIManager.setLookAndFeel(
                   UIManager.getSystemLookAndFeelClassName());
           } 
           catch (UnsupportedLookAndFeelException e) {
              System.out.println("Unsupported Look And Feel. Error: "  + e.getMessage());
           }
           catch (ClassNotFoundException e) {
              System.out.println("Class Not Found. Error: "  + e.getMessage());
           }
           catch (InstantiationException e) {
             System.out.println("Instantiation error. Error: "  + e.getMessage());
           }
        catch (IllegalAccessException e) {
           System.out.println("Illegal Access Exception. Error:  " + e.getMessage());
        }            

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {

               Avenue  avenueForm = new Avenue();
               //Custom form icon
               String imgPath = System.getProperty("user.dir") + "\\src\\images\\";
               avenueForm.setIconImage(Toolkit.getDefaultToolkit().getImage(imgPath + "telepass_icon.gif"));
               avenueForm.setVisible(true);
               avenueForm.setExtendedState(JFrame.MAXIMIZED_BOTH); // maximized form                  
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    public javax.swing.JButton cardTransIconButton;
    public javax.swing.JButton customerTransIconButton;
    public javax.swing.JButton customersIconButton;
    private javax.swing.JButton exitIconButton;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenu jMnuAdmin;
    private javax.swing.JMenuItem jMnuCardTransactions;
    private javax.swing.JMenuItem jMnuCollectToll;
    private javax.swing.JMenuItem jMnuCustomerTransactions;
    private javax.swing.JMenuItem jMnuCustomers;
    private javax.swing.JMenu jMnuExit;
    private javax.swing.JMenuItem jMnuPrograms;
    private javax.swing.JMenuItem jMnuRoles;
    private javax.swing.JMenu jMnuTolls;
    private javax.swing.JMenu jMnuTransactions;
    private javax.swing.JMenuItem jMnuUsers;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JTextField jTxtCurrentUser;
    private javax.swing.JTextField jTxtUserStation;
    public javax.swing.JButton programsIconButton;
    public javax.swing.JButton rolesIconButton;
    public javax.swing.JButton tollIconButton;
    public javax.swing.JButton usersIconButton;
    // End of variables declaration//GEN-END:variables
private AppUser au;

    public JMenuItem getjMenuCustomers() {
        return jMnuCustomers;
    }

    public void setjMenuCustomers(JMenuItem jMenuItem1) {
        this.jMnuCustomers = jMenuItem1;
    }

    public JMenuItem getjMenuCollectToll() {
        return jMnuCollectToll;
    }

    public void setjMenuCollectToll(JMenuItem jMenuItem2) {
        this.jMnuCollectToll = jMenuItem2;
    }

    public JMenuItem getjMenuUsers() {
        return jMnuUsers;
    }

    public void setjMenuUsers(JMenuItem jMenuItem3) {
        this.jMnuUsers = jMenuItem3;
    }

    public JMenuItem getjMenuCardTransactions() {
        return jMnuCardTransactions;
    }

    public void setjMenuCardTransactions(JMenuItem jMenuItem5) {
        this.jMnuCardTransactions = jMenuItem5;
    }

    public JMenuItem getjMenuCustomerTransactions() {
        return jMnuCustomerTransactions;
    }

    public void setjMenuCustomerTransactions(JMenuItem jMenuItem6) {
        this.jMnuCustomerTransactions = jMenuItem6;
    }

    public JMenuItem getjMenuRoles() {
        return jMnuRoles;
    }

    public void setjMenuRoles(JMenuItem jMenuItem7) {
        this.jMnuRoles = jMenuItem7;
    }

    public JMenuItem getjMenuPrograms() {
        return jMnuPrograms;
    }

    public void setjMenuPrograms(JMenuItem jMenuItem8) {
        this.jMnuPrograms = jMenuItem8;
    }

    
}
